using System.Collections;
using UnityEngine;

public class ZoomAtBarController : MonoBehaviour
{
	public Transform bar;

	public Transform sea;

	public Transform topLeafes;

	public Transform bottomLeafes;

	public Transform dude;

	public Transform stuff;

	public Transform buttons;

	[HideInInspector]
	public Transform[] glass;

	private bool zoomAtBar;

	public void ZoomAtBar()
	{
		AudioController.instance.Play("start_game_zoom");
		zoomAtBar = true;
		ZoomTransform(bar, 3f, 1f);
		MoveTransform(bar, Vector3.up * 2.46f, 1f);
		ZoomTransform(sea, 1.1f, 1f);
		MoveTransform(topLeafes, new Vector3(-4.88f, 6.15f, 0f), 1f);
		MoveTransform(bottomLeafes, new Vector3(7.09f, -0.9f, 0f), 1f);
		ZoomTransform(topLeafes, 1.755f, 1f);
		ZoomTransform(bottomLeafes, 2.2f, 1f);
		MoveTransform(dude, new Vector3(10f, -0.65f, 0f), 1f);
		MoveTransform(stuff, new Vector3(-10f, 1.77f, 0f), 1f);
		MoveTransform(buttons, new Vector3(0f, -14f, 0f), 1f);
		Transform[] array = glass;
		foreach (Transform transform in array)
		{
			ZoomTransform(transform, 1f, 1f);
			Transform transform2 = transform;
			Vector3 a = Vector3.up * -5.45f;
			Vector3 right = Vector3.right;
			Vector3 position = transform.position;
			MoveTransform(transform2, a + right * position.x * 3f, 1f);
		}
	}

	private void ZoomTransform(Transform transform, float to, float time)
	{
		Vector3 vector = new Vector3(to, to, 1f);
		iTween.ScaleTo(transform.gameObject, iTween.Hash("scale", vector, "time", time, "easetype", iTween.EaseType.easeInOutCubic));
	}

	private void MoveTransform(Transform transform, Vector3 to, float time)
	{
		iTween.MoveTo(transform.gameObject, iTween.Hash("x", to.x, "y", to.y, "time", time, "easetype", iTween.EaseType.easeInOutCubic));
	}

	public void ResetZoom()
	{
		ZoomTransform(bar, 1f, 1f);
		MoveTransform(bar, Vector3.zero, 1f);
		ZoomTransform(sea, 1f, 1f);
		MoveTransform(topLeafes, new Vector3(-2.13f, 2.07f, 0f), 1f);
		MoveTransform(bottomLeafes, new Vector3(2.88f, -1.01f, 0f), 1f);
		ZoomTransform(topLeafes, 1f, 1f);
		ZoomTransform(bottomLeafes, 1f, 1f);
		MoveTransform(dude, new Vector3(1.92f, -0.65f, 0f), 1f);
		MoveTransform(stuff, new Vector3(-2.27f, -0.23f, 0f), 1f);
		MoveTransform(buttons, new Vector3(0f, -4.54f, 0f), 1f);
		StartCoroutine(EndOfZoomOut());
	}

	private IEnumerator EndOfZoomOut()
	{
		yield return new WaitForSeconds(1.2f);
		zoomAtBar = false;
	}

	public bool IsZoomAtBar()
	{
		return zoomAtBar;
	}
}
